<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>过滤器入门</title>
</head>
<body>
<div id="app">
    <input type="text" v-model="msg">
    <div>{{msg | upper}}</div>
    <div>{{msg | upper | lower}}</div>
    <div :id="msg | upper">测试数据</div>
</div>

<!-- 生产环境版本，优化了尺寸和速度 -->
<script src="https://cdn.jsdelivr.net/npm/vue"></script>
<script type="text/javascript">
    /*
    过滤器
     */
    // Vue.filter("upper", function (val) {
    //     return val.charAt(0).toUpperCase() + val.slice(1);
    // });
    Vue.filter("lower", function (val) {
        return val.charAt(0).toLocaleLowerCase() + val.substring(1);
    });

    var vue = new Vue({
        el: "#app",
        data: {
            msg: ""
        },
        //局部过滤器
        filters: {
            upper: function (val) {
                return val.charAt(0).toUpperCase() + val.slice(1);
            }
        }
    })
</script>
</body>
</html>
